<?php
class mtestimonialcontent extends CI_Model{
	var $testimonial = "testimonial_content";

	function __construct()
	{
		parent::__construct();
	}
	
	function setData($id_testimonial,$id_submenu,$nama_testimonial,$date_testimonial,$file_testimonial,$description_testimonial)
	{
		$this->id_testimonial= $id_testimonial;
		$this->id_submenu= $id_submenu;
		$this->nama_testimonial= $nama_testimonial;
		$this->date_testimonial= $date_testimonial;
		$this->file_testimonial= $file_testimonial;
		$this->description_testimonial= $description_testimonial;
	}
	
	function getList($page,$uri_segment){
		$query = $this->db->get($this->testimonial, $page, $uri_segment);
		if($query->num_rows() > 0){
			foreach($query->result_array() as $row){
				$result[] = $row;
			}
			return $result;
		} else {
			return false;
		}	
	}
	
	function getComboList(){
		$query = $this->db->get($this->testimonial);
		if($query->num_rows() > 0){
			foreach($query->result_array() as $row){
				$result[] = $row;
			}
			return $result;
		} else {
			return false;
		}	
	}
	
	function create()
	{	
		$arrayData = array(
			'id_testimonial'=>$this->id_testimonial,
			'id_submenu'=>$this->id_submenu,
			'nama_testimonial'=>$this->nama_testimonial,
			'date_testimonial'=>$this->date_testimonial,
			'file_testimonial'=>$this->file_testimonial,
			'description_testimonial'=>$this->description_testimonial
		);
		return $this->db->insert($this->testimonial, $arrayData);
	}
	
	function update($id_testimonial)
	{
		$arrayData = array(
			'id_submenu'=>$this->id_submenu,
			'nama_testimonial'=>$this->nama_testimonial,
			'date_testimonial'=>$this->date_testimonial,
			'file_testimonial'=>$this->file_testimonial,
			'description_testimonial'=>$this->description_testimonial
		);
		$this->db->where('id_testimonial', $id_testimonial);
		return $this->db->update($this->testimonial, $arrayData);
	}
        
	function remove($id_testimonial)
	{
		$this->db->where('id_testimonial', $id_testimonial);
		return $this->db->delete($this->testimonial);
	}	
	
	function detail($id_testimonial)
	{
		$this->db->where('id_testimonial', $id_testimonial);
		$query = $this->db->get($this->testimonial);	
		return $query->result_array();
	}
	
	function getListSearch($name){
		$this->db->like('nama_testimonial',$name);
		$query = $this->db->get($this->testimonial);
		if($query->num_rows() > 0){
			foreach($query->result_array() as $row){
				$result[] = $row;
			}
			return $result;
		} else {
			return false;
		}	
	}
	
	function getForWeb($id_submenu)
	{
		$this->db->where('id_submenu', $id_submenu);
		$query = $this->db->get($this->testimonial);	
		return $query->result_array();
	}
}
?>